﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="DigDes.DSchool.SUPS.Web.UI.WebForm3" %>



<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <div>

        <asp:ObjectDataSource runat="server" ID="CargoDetailsDataSource" TypeName="DigDes.DSchool.SUPS.DataAccess.Database.SelectorCargoDAC" SelectMethod="SelectCargoRow" OldValuesParameterFormatString="original_{0}" DeleteMethod="DeleteCargo" InsertMethod="InsertCargo" UpdateMethod="UpdateCargo" OnSelecting="CargoDetailsDataSource_Selecting">
            <DeleteParameters>
                <asp:ControlParameter ControlID="GridViewForCargo" PropertyName="SelectedValue" DefaultValue="0" Name="cargoID" Type="Int32"></asp:ControlParameter>
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="cargoName" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoDescription" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoShortCode" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoCode" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoETSNGName" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoCodeGNG" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoGNGName" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoMnemocode" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoIsUsed" Type="Boolean" DefaultValue="false"></asp:Parameter>
                <asp:Parameter Name="cargoIsEmpty" Type="Boolean" DefaultValue="false"></asp:Parameter>
            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="GridViewForCargo" PropertyName="SelectedValue" DefaultValue="0" Name="index" Type="Int32"></asp:ControlParameter>
                <asp:Parameter DefaultValue="1" Name="pageIndex" Type="Int32"></asp:Parameter>
                <asp:Parameter DefaultValue="10" Name="pageSize" Type="Int32"></asp:Parameter>
            </SelectParameters>
            <UpdateParameters>
                <asp:ControlParameter ControlID="GridViewForCargo" PropertyName="SelectedValue" DefaultValue="0" Name="cargoID" Type="Int32"></asp:ControlParameter>
                <asp:Parameter Name="cargoName" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoDescription" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoShortCode" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoCode" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoETSNGName" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoCodeGNG" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoGNGName" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoMnemocode" Type="String" DefaultValue=""></asp:Parameter>
                <asp:Parameter Name="cargoIsUsed" Type="Boolean" DefaultValue="false"></asp:Parameter>
                <asp:Parameter Name="cargoIsEmpty" Type="Boolean" DefaultValue="false"></asp:Parameter>
            </UpdateParameters>
        </asp:ObjectDataSource>

        <asp:ObjectDataSource ID="CargoDataSource"
            runat="server" 
            EnablePaging="true" 
            SelectCountMethod="CountCargo"         
            TypeName="DigDes.DSchool.SUPS.DataAccess.Database.SelectorCargoDAC" 
            SelectMethod="SelectCargo" 
            OldValuesParameterFormatString="original_{0}">       
        </asp:ObjectDataSource>



        <asp:UpdatePanel ID="UpdatePanel1"
            UpdateMode="Conditional"
            runat="server">
            <ContentTemplate>

                <fieldset>

                    <asp:GridView ID="GridViewForCargo"
                        runat="server"                        
                        DataSourceID="CargoDataSource" 
                        AllowPaging="true"
                        AutoGenerateColumns="False"
                        OnSelectedIndexChanged="GridView_OnSelectedIndexChanged"
                        AutoGenerateSelectButton="true"
                        DataKeyNames="Id">

                        <Columns>
                            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"></asp:BoundField>
                            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description"></asp:BoundField>
                            <asp:BoundField DataField="ShortCode" HeaderText="ShortCode" SortExpression="ShortCode"></asp:BoundField>
                            <asp:BoundField DataField="Code" HeaderText="Code" SortExpression="Code"></asp:BoundField>
                            <asp:BoundField DataField="NameETSNG" HeaderText="NameETSNG" SortExpression="NameETSNG"></asp:BoundField>
                            <asp:BoundField DataField="CodeGNG" HeaderText="CodeGNG" SortExpression="CodeGNG"></asp:BoundField>
                            <asp:BoundField DataField="NameGNG" HeaderText="NameGNG" SortExpression="NameGNG"></asp:BoundField>
                            <asp:BoundField DataField="Mnemocode" HeaderText="Mnemocode" SortExpression="Mnemocode"></asp:BoundField>
                            <asp:CheckBoxField DataField="IsUsed" HeaderText="IsUsed" SortExpression="IsUsed"></asp:CheckBoxField>
                            <asp:CheckBoxField DataField="IsEmpty" HeaderText="IsEmpty" SortExpression="IsEmpty"></asp:CheckBoxField>

                        </Columns>
                    </asp:GridView>
                
           

        <br />
        <asp:Button runat="server" Text="Добавить" OnClick="OnAddButton" ID="NewButton" />
        &nbsp;
         <asp:Button runat="server" Text="Редактировать" OnClick="OnEditButton" ID="EditButtonID" Enabled="false" />
        &nbsp;
        <asp:Button runat="server" Text="Удалить" OnClick="OnDeleteButton" ID="DeleteButtonID" Enabled="false" />

        <br />
        <asp:DetailsView
            runat="server"
            ID="CargoDetailsView"
            DataSourceID="CargoDetailsDataSource"
            AutoGenerateRows="False"
            DefaultMode="ReadOnly">

            <Fields>
                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelName" runat="server" Text="Груз" AssociatedControlID="DetailsCargoName"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoName" runat="server" Text='<%# Eval("Name") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertName" runat="server" Text="Груз" AssociatedControlID="InsertDetailsCargoName"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditName" runat="server" Text="Груз" AssociatedControlID="EditDetailsCargoName"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelDescription" runat="server" Text="Описание груза" AssociatedControlID="DetailsCargoDescription"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoDescription" runat="server" Text='<%# Eval("Description") %>' Enabled="false" TextMode="MultiLine"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertDescription" runat="server" Text="Описание груза" AssociatedControlID="InsertDetailsCargoDescription"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoDescription" runat="server" Text='<%# Bind("Description") %>' TextMode="MultiLine"></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditDescription" runat="server" Text="Описание груза" AssociatedControlID="EditDetailsCargoDescription"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoDescription" runat="server" Text='<%# Bind("Description") %>' TextMode="MultiLine"></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelShortCode" runat="server" Text="Код груза" AssociatedControlID="DetailsCargoShortCode"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoShortCode" runat="server" Text='<%# Eval("ShortCode") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertShortCode" runat="server" Text="Код груза" AssociatedControlID="InsertDetailsCargoShortCode"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoShortCode" runat="server" Text='<%# Bind("ShortCode") %>'></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditShortCode" runat="server" Text="Код груза" AssociatedControlID="EditDetailsCargoShortCode"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoShortCode" runat="server" Text='<%# Bind("ShortCode") %>'></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelCode" runat="server" Text="Код груза в ETSNG" AssociatedControlID="DetailsCargoCode"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoCode" runat="server" Text='<%# Eval("Code") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertCode" runat="server" Text="Код груза в ETSNG" AssociatedControlID="InsertDetailsCargoCode"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoCode" runat="server" Text='<%# Bind("Code") %>'></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditCode" runat="server" Text="Код груза в ETSNG" AssociatedControlID="EditDetailsCargoCode"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoCode" runat="server" Text='<%# Bind("Code") %>'></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelNameETSNG" runat="server" Text="Название груза в ETSNG" AssociatedControlID="DetailsCargoNameETSNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoNameETSNG" runat="server" Text='<%# Eval("NameETSNG") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertNameETSNG" runat="server" Text="Название груза в ETSNG" AssociatedControlID="InsertDetailsCargoNameETSNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoNameETSNG" runat="server" Text='<%# Bind("NameETSNG") %>' EnableTheming="true"></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditNameETSNG" runat="server" Text="Название груза в ETSNG" AssociatedControlID="EditDetailsCargoNameETSNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoNameETSNG" runat="server" Text='<%# Bind("NameETSNG") %>'></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelCodeGNG" runat="server" Text="Код груза в GNG" AssociatedControlID="DetailsCargoCodeGNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoCodeGNG" runat="server" Text='<%# Eval("CodeGNG") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertCodeGNG" runat="server" Text="Код груза в GNG" AssociatedControlID="InsertDetailsCargoCodeGNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoCodeGNG" runat="server" Text='<%# Bind("CodeGNG") %>'></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditCodeGNG" runat="server" Text="Код груза в GNG" AssociatedControlID="EditDetailsCargoCodeGNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoCodeGNG" runat="server" Text='<%# Bind("CodeGNG") %>'></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelNameGNG" runat="server" Text="Название груза в GNG" AssociatedControlID="DetailsCargoNameGNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoNameGNG" runat="server" Text='<%# Eval("NameGNG") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertNameGNG" runat="server" Text="Название груза в GNG" AssociatedControlID="InsertDetailsCargoNameGNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoNameGNG" runat="server" Text='<%# Bind("NameGNG") %>'></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditNameGNG" runat="server" Text="Название груза в GNG" AssociatedControlID="EditDetailsCargoNameGNG"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoNameGNG" runat="server" Text='<%# Bind("NameGNG") %>'></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelMnemocode" runat="server" Text="Мнемокод" AssociatedControlID="DetailsCargoMnemocode"></asp:Label>
                        <br />
                        <asp:TextBox ID="DetailsCargoMnemocode" runat="server" Text='<%# Eval("Mnemocode") %>' Enabled="false"></asp:TextBox>
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertMnemocode" runat="server" Text="Мнемокод" AssociatedControlID="InsertDetailsCargoMnemocode"></asp:Label>
                        <br />
                        <asp:TextBox ID="InsertDetailsCargoMnemocode" runat="server" Text='<%# Bind("Mnemocode") %>'></asp:TextBox>
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditMnemocode" runat="server" Text="Мнемокод" AssociatedControlID="EditDetailsCargoMnemocode"></asp:Label>
                        <br />
                        <asp:TextBox ID="EditDetailsCargoMnemocode" runat="server" Text='<%# Bind("Mnemocode") %>'></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">
                    <ItemTemplate>
                        <asp:Label ID="LabelIsUsed" runat="server" Text="Используется" AssociatedControlID="ItemDetailsCargoIsUsed"></asp:Label>
                        <br />
                        <asp:CheckBox ID="ItemDetailsCargoIsUsed" runat="server" Checked='<%# Eval("IsUsed") %>' Enabled="false" />
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertIsUsed" runat="server" Text="Используется" AssociatedControlID="InsertDetailsCargoIsUsed"></asp:Label>
                        <br />
                        <asp:CheckBox ID="InsertDetailsCargoIsUsed" runat="server" Checked='<%# Bind("IsUsed") %>' />
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditIsUsed" runat="server" Text="Используется" AssociatedControlID="EditDetailsCargoIsUsed"></asp:Label>
                        <br />
                        <asp:CheckBox ID="EditDetailsCargoIsUsed" runat="server" Checked='<%# Bind("IsUsed") %>' />
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField ShowHeader="false">

                    <ItemTemplate>
                        <asp:Label ID="LabelIsEmpty" runat="server" Text="Порожний" AssociatedControlID="ItemDetailsCargoIsEmpty"></asp:Label>
                        <br />
                        <asp:CheckBox ID="ItemDetailsCargoIsEmpty" runat="server" Checked='<%# Eval("IsEmpty") %>' Enabled="false" />
                    </ItemTemplate>

                    <InsertItemTemplate>
                        <asp:Label ID="LabelInsertIsEmpty" runat="server" Text="Порожний" AssociatedControlID="InsertDetailsCargoIsEmpty"></asp:Label>
                        <br />
                        <asp:CheckBox ID="InsertDetailsCargoIsEmpty" runat="server" Checked='<%# Bind("IsEmpty") %>' />
                    </InsertItemTemplate>

                    <EditItemTemplate>
                        <asp:Label ID="LabelEditIsEmpty" runat="server" Text="Порожний" AssociatedControlID="EditDetailsCargoIsEmpty"></asp:Label>
                        <br />
                        <asp:CheckBox ID="EditDetailsCargoIsEmpty" runat="server" Checked='<%# Bind("IsEmpty") %>' />
                    </EditItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField Visible="true">
                    <InsertItemTemplate>
                        <asp:Button ID="SaveInsetButton" Text="Сохранить" runat="server" OnClick="OnSaveInsert" />
                        <asp:Button ID="CancelInsetButton" Text="Отмена" runat="server" OnClick="OnCancel" />
                    </InsertItemTemplate>
                    <EditItemTemplate>
                        <asp:Button ID="SaveEditButton" Text="Сохранить" runat="server" OnClick="OnSaveEdit" />
                        <asp:Button ID="CancelEditButton" Text="Отмена" runat="server" OnClick="OnCancel" />
                    </EditItemTemplate>

                </asp:TemplateField>


            </Fields>
        </asp:DetailsView>
                    </fieldset>
                  </ContentTemplate>
        </asp:UpdatePanel>
        <%--<asp:Label runat="server" Text="134"></asp:Label>--%>

    </div>
</asp:Content>
